//
//  RootViewController.swift
//  CompareNew
//
//  Created by 唐先才 on 16/1/27.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import Foundation
import UIKit

class RootViewController: UITabBarController {
  
    override func viewDidLoad() {
        super.viewDidLoad()
        self.createControllers()
    }
    
    func createControllers() {
        let homePage = HomePageViewController()
        let nav1 = TxcNavController(rootViewController: homePage)
        nav1.tabBarItem = UITabBarItem(title: "首页", image: UIImage(named: "home_gray"), selectedImage: UIImage(named: "home_red"))
        let search = SearchViewController()
        let nav2 = TxcNavController(rootViewController: search)
        nav2.tabBarItem = UITabBarItem(title: "搜索", image: UIImage(named: "search_gray"), selectedImage: UIImage(named: "search_red"))
        nav2.navigationBar.barTintColor = MAIN_COLOR
        let shoppingCart = ShoppingCartViewController()
        let nav3 = TxcNavController(rootViewController: shoppingCart)
        nav3.tabBarItem = UITabBarItem(title: "购物车", image: UIImage(named: "cart_gray"), selectedImage: UIImage(named: "cart_red"))
        nav3.title = "购物车"
        let my = MyViewController()
        let nav4 = TxcNavController(rootViewController: my)
        nav4.tabBarItem = UITabBarItem(title: "我", image: UIImage(named: "my_gray"), selectedImage: UIImage(named: "my_red"))
        let controllersArr = [nav1, nav2, nav3, nav4]
        self.viewControllers = controllersArr
        self.tabBar.tintColor = UIColor.redColor()
        
        //self.tabBar.selectedImageTintColor = UIColor.redColor()
        
        //如何用字符串的形式循环创建类
//        print(NSClassFromString("CompareBuying.HomePageViewController"))
//        let namesArray = ["HomePageViewController", "SearchViewController", "ShoppingCartViewController", "MyViewController"];
//        let imageArray = ["home_gray", "search_gray", "cart_gary", "my_gray"];
//        let sImageArray = ["home_red", "search_red", "cart_red", "my_red"];
//        let titleArray = ["首页", "搜索", "购物车", "我"];
//        for index in 0...3 {
//          
//        }
        
    
    }
}